USE [BMIG_MENSUAL_POST_CADENA]

 -- creating the store procedure
IF EXISTS (SELECT name 
	   FROM   sysobjects 
	   WHERE  name = 'WASP_M0009_DROP_CREATE'
	   AND 	  type = 'P') 
	DROP PROCEDURE [dbo].[WASP_M0009_DROP_CREATE]
GO

CREATE PROCEDURE [dbo].[WASP_M0009_DROP_CREATE] AS
begin

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AS_ingreso_produccion_UF_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[AS_ingreso_produccion_UF_ant]
    END
    
    BEGIN
      CREATE TABLE [dbo].[AS_ingreso_produccion_UF_ant] (
      	[TipoRegistro] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
      	[PeriodoPro] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[FechaEnvio] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[NroCorrelativoArchivo] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[TipoMovimiento] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[NroProducto] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[NroPoliza] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[CODAGEN] [numeric](2, 0) NULL ,
      	[NroCredito] [varchar] (18) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[RutAsegurado] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[DV Rut Asegurado] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[Nombre Asegurado] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[DireccionAsegurado] [varchar] (65) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[TelefonoAsegurado] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[CodigoComuna] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[DescripcionComuna] [char] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[CodigoCiudad] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[DescripcionCuidad] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[CodigoRegion] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[DescripcionRegion] [char] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[VigenciaDesde] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[VigenciaHasta] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[CuotasPactadas] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[PrimaNetaCaja] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      	[PrimaBrutaCaja] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
      ) ON [PRIMARY]
    END
END    

